package org.example.service.impl;

import org.example.dao.LocationDao;
import org.example.entity.Location;
import org.example.service.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author CoderXshuai
 * @date 2020/9/3/0003 15:14
 */
@Service
public class LocationServiceImpl implements LocationService {
    @Autowired
    private LocationDao locationDao;

    @Override
    public void insertLocation(Location location) {
        locationDao.save(location);
    }

    @Override
    public void deleteLocation(Integer eid) {
        locationDao.deleteById(eid);
    }

    @Override
    public void updateLocation(Location location) {
        locationDao.save(location);
    }

    @Override
    public List<Location> findAllLocation() {
        Iterable<Location> locationIterable = locationDao.findAll();
        List<Location> locationList = new ArrayList<>();
        locationIterable.forEach(locationList::add);
        return locationList;
    }
}
